#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        int n, m, l, r;
        cin >> n >> m >> l >> r;
        int diff = n - m;
        // 计算 n 天区间中点相对于 0 的偏移
        int mid_n = (l + r) / 2;
        // 计算 m 天区间长度
        int len_m = r - l - diff;
        int l_prime = mid_n - len_m / 2;
        int r_prime = mid_n + (len_m + len_m % 2) / 2;
        cout << l_prime << " " << r_prime << endl;
    }
    return 0;
}